<template>
  <div class="info">
    <el-form :model='searchInfo' inline></el-form>
    <el-table :data=commentList style="width: 100%" border >
      <el-table-column type="expand">
        <template slot-scope="props">
          <el-form label-position="left" inline class="demo-table-expand">
            <el-row>
              <el-col :span="8">
                <el-form-item label="电影名：">
                  <span>{{props.row.movieName}}</span>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="会员名：">
                  <span>{{props.row.vipName}}</span>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </template>
      </el-table-column>
      <el-table-column label="编号" prop="commentId"  align="center" />
      <el-table-column label="评论人ID" prop="vipId"  align="center" />
      <el-table-column label="评分" prop="score"  align="center" />
      <el-table-column label="评论内容" prop="content"  align="center" />
      <el-table-column label="电影ID" prop="movieId"  align="center" />
      <el-table-column label="信息状态" prop="status" align="center">
        <template slot-scope="scope">
          <el-button type="danger" v-if="scope.row.status===0">禁用</el-button>
          <el-button type="success" v-if="scope.row.status===1">可用</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination layout="total,prev,pager,next,sizes,jumper"
                   :total="pageInfo.totalCount"
                   :page-size="pageInfo.pageSize"
                   :current-page="pageInfo.currPage"
                   :page-sizes="[5,10,20,30,50,100]"
                   @size-change="sizeChange"
                   @current-change="currentChange"
    />
  </div>
</template>

<script>

export default {
  name: 'Comment',
  data () {
    return {
      commentList: [],
      searchInfo: {
        page: 1,
        limit: 10
      },
      pageInfo: {}
    }
  },
  methods: {
    init (vipId) {
      this.searchInfo = { ...this.searchInfo }
      this.$http.get(`/sys/vip/comment/${vipId}`, this.searchInfo).then(({ data }) => {
        if (data.code === 200) {
          this.commentList = data.data.list
          this.pageInfo = data.data
        }
      })
    },
    sizeChange (limit) {
      this.searchInfo.limit = limit
      this.init()
    },
    currentChange (page) {
      this.searchInfo.page = page
      this.init()
    }
  },
  created () {
    this.$nextTick(() => {
      this.init()
    })
  }
}
</script>

<style scoped>

</style>
